<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	 <%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=request.getContextPath()%>/">
<meta charset="UTF-8">
<script type="text/javascript" src="js/public/jquery-1.9.1/jquery.js"></script>
<title>Insert title here</title>
<link href="css/style.css" rel="stylesheet">
<style type="text/css">
button {
	height: 30px;
	font-weight: 900;
}

#pageButton {
	margin-left: auto;
	text-align: center;
}

#operation {
	width: 100%;
	height: 300px;
}

#addClassButtonLift {
	width: 40%;
	text-align: center;
}

#addClassButton {
	margin-left: 60px;
	margin-right: 40px;
}

#houseOperation {
	margin-top: 30px;
	width: 100%;
	height: 270px;
	padding-left: 30px;
	border:
}

#houseOperation-left, #houseOperation-right {
	float: left;
	height: 96%;
	width: 45%;
}

#addhouse {
	margin-left: 60px;
	margin-top: 40px;
	margin-right: 90px;
}

#houseInf {
	margin-left: 60px;
	margin-top: 40px;
	margin-right: 60px;
}

#houseOperation-right {
	border: 2px solid black;
}

#houseOperation-right div {
	line-height: 50px;
}

#findHouse {
	margin-left: 200px;
	margin-top: 60px;
}

button {
	box-shadow: 4px 4px 2px #000;
}

/* 

房间设施 */

#houseEqui{
width:500px;
border: 2px solid black;
position: fixed;
background-color: #cfcfcf;
top:60px;
left: 540px;
display: none;
}

#houseEquiTitle{
  text-align: center;
  line-height: 30px;
}

#houseEquiTable {
	width:500px;
	height: 100px;
	border: 2px solid black;
	text-align: center;
	border-spacing: 0;
	border-collapse: collapse;
}

#houseEquiTbody {
	display: block;
	height: 116px;
	overflow-y: scroll;
}

#houseEquiThead, #houseEquiTbody tr {
	display: table;
	width: 100%;
	table-layout: fixed;
}

/* .cName,.cTime{
    border-right: 2px solid black;
} */
/*关键设置：滚动条默认宽度是16px 将thead的宽度减16px*/
#houseEquiThead {
	width: calc(100% - 1em)
}

#houseEquiTable tr {
	border-bottom: 1px solid black;
	height: 35px;
}

#houseEquiTable tr:hover {
	background-color: #ccc;
	cursor: pointer;
}
.houseEqui-left{
     margin-left:30px;
     margin-right:30px;
     text-align: right;
     line-height: 60px;
     height: 100%;
}
.houseEqui-right{
     width: 150px;
}
#buttonEq{
   line-height: 80px;
}

#buttonEq button {
	margin-left: 40px;
}


/* 添加房间表格 */
#addHouseDiv{
  border: 2px black solid;
  width: 550px;
  background-color: #808080;
  position: fixed;
  top:60px;
  left: 500px;
  display: none;
}

#addHouseDiv div{
   line-height: 40px;
}

#addHouseTable{
   border-top: 2px black solid;
   border-bottom: 2px black solid;
   width: 100%;
}

#addHouseTable tr{
    height: 60px;
}
#addHouseDivtitle{
   text-align: center;
}

#addHousetr button{
   margin-left: 150px;
}







/* 查看房间详细信息 */
#showHouseInf {
	border: 2px black solid;
	width: 530px;
	height: 450px;
	background-color: #808080;
	position:fixed;
	 top:60px;
  left: 500px;
  display: none;
}

#showHouseInfTitle {
	border: 2px black solid;
	line-height: 40px;
	text-align: center;
}

#showHouseInfTable {
	width: 440px;
	line-height: 30px;
	margin-left: 30px;
}

/* .showHouseInfTableLeft {
	text-align: right;
} */

#showStudentInfTable {
	width: 90%;
	border: 2px solid black;
	text-align: center;
	border-spacing: 0;
	border-collapse: collapse;
	margin-left: 30px;
}

#showStudentInfTbody {
	display: block;
	height: 116px;
	overflow-y: scroll;
}

#showStudentInfThead, #showStudentInfTbody tr {
	display: table;
	width: 100%;
	table-layout: fixed;
}

/* .cName,.cTime{
    border-right: 2px solid black;
} */
/*关键设置：滚动条默认宽度是16px 将thead的宽度减16px*/
#showStudentInfThead {
	width: calc(100% - 1em)
}

#showStudentInfTable tr {
	border-bottom: 1px solid black;
	height: 35px;
}

#showStudentInfTable tr:hover {
	background-color: #ccc;
	cursor: pointer;
}



</style>
</head>
<body>
       <!--    保存hid -->
	<input type="hidden" id="witchOption">
	<!-- 保存操作哪一行 -->
	<input type="hidden" id="witchTr">
	<!-- 保存哪一行对应的值 -->
	<input type="hidden" id="witchTrValue">
	<!-- 保存house的状态 -->
	<input type="hidden" id="witchHsta">



	<!-- 房间设备 -->
	<div id="houseEqui">
		<div id="houseEquiTitle">
			<b>房间设施维护</b>
		</div>
		<table id="houseEquiTable">
			<thead id="houseEquiThead">
				<tr>
					<th>损坏描述</th>
					<th>损坏日期</th>
					<th>是否解决</th>
				</tr>
			</thead>
			<tbody id="houseEquiTbody">
				<tr>
					<td>损坏描述</td>
					<td>损坏日期</td>
					<td>是否解决</td>
				</tr>
				<tr>
					<td>损坏描述</td>
					<td>损坏日期</td>
					<td>是否解决</td>
				</tr>
			</tbody>
		</table>
		<div id="houseEqui-time">
			<span class="houseEqui-left">报损日期:</span> <span
				class="houseEqui-right"><input type="date" id="houseEquiTime"></span>
		</div>
		<div id="houseEqui-exp">
			<span class="houseEqui-left">损坏描述:</span> <span
				class="houseEqui-right"><input type="text" id="houseEquiE"></span>
		</div>
		<div id="buttonEq">
			<button id="addEq">添加设备受损记录</button>
			<button id="deleEq">处理已受损设备</button>
			<button id="exitEq">退出</button>
		</div>

	</div>







	<div id="content">
		
		
		<div id="option">
			<ul id="messageSystem">
				<li ><a href="jsp/index.jsp">宿舍管理系统</a>
					<ul>
						<li>资料管理
							<ul>
								<li><a href="jsp/class.jsp">班级管理</a></li>
								<li><a href="jsp/student.jsp">学生管理</a></li>
							</ul>
						</li>
						
					
						<li>房间管理
							<ul>
								<li><a href="jsp/house.jsp">房间信息</a></li>
							</ul>
						</li>
				
					</ul>
				</li>
			</ul>
			<ul>
			  <li><a href="/DormitoryManagement/logout">注销</a></li>
			</ul>
		</div>
		<div id="show">
			<!-- 展示列表 -->
			<table id="tableShow">
				<thead id="theadShow">
					<tr>
						<th>房间地址</th>
						<th>容纳人数</th>
						<th>已住人数</th>
						<th>房租</th>
						<th>房间状态</th>
						<th>房东</th>
						<th>房东电话</th>
						<th>房间类型</th>
					</tr>
				</thead>

			</table>





<!--  查看房间详细信息  -->
<div id="showHouseInf">
		<div id="showHouseInfTitle">
			<b>查看房间信息</b>
		</div>
		<table id="showHouseInfTable">
			<tr>
				<td>房间地址:</td>
				<td id="showHouseInfAddress"></td>
				<td class="showHouseInfTableLeft">房间户型</td>
				<td id="showHouseInfSize"></td>
			</tr>
			<tr>
				<td>可容纳人数:</td>
				<td id="showHouseInfSum"></td>
				<td class="showHouseInfTableLeft">已住人数</td>
				<td id="showHouseInfNum"></td>
			</tr>
			<tr>
				<td>房租:</td>
				<td id="showHouseInfRent"></td>
				<td class="showHouseInfTableLeft">支付方式</td>
				<td id="showHouseInfPay"></td>
			</tr>
			<tr>
				<td>房东:</td>
				<td id="showHouseInfLid"></td>
				<td class="showHouseInfTableLeft">房东电话</td>
				<td id="showHouseInfLphone"></td>
			</tr>
			<tr>
				<td>房间状态:</td>
				<td id="showHouseInfStatus"></td>
				<td class="showHouseInfTableLeft">房间类型</td>
				<td id="showHouseInfType"></td>
			</tr>
			<tr>
				<td>租房日期:</td>
				<td id="showHouseInfTime"></td>
				<td></td>
				<td></td>
			</tr>


		</table>

		<table id="showStudentInfTable">
			<thead id="showStudentInfThead">
				<tr>
					<th>学生姓名</th>
					<th>所在班级</th>
					<th>联系电话</th>
				</tr>
			</thead>
			<tbody id="showStudentInfTbody">

			</tbody>

		</table>
		<button id="showHouseInfExit"
			style="margin-left: 250px; margin-top: 10px;">退出</button>
	</div>









<!-- 添加房间表格 -->
<div id="addHouseDiv">
          <div id="addHouseDivtitle"><b>添加房间信息</b></div>
          <table id="addHouseTable">
               <tr>
                  <td>房间地址:</td>
                  <td><input type="text" id="addHouseAddress"></td>
                  <td>房间户型:</td>
                  <td>
                    <select id="addHouseSize">
                           <option value=0>一室一厅</option>
                           <option value=1>两室一厅</option>
                           <option value=2>三室一厅</option>
                           <option value=3>三室两厅</option>
                    </select>
                  </td>
               </tr>
               
               
               <tr>
                  <td>可容纳数量:</td>
                  <td ><input type="text" id="addHouseSum"></td>
                  <td>房间类型:</td>
                  <td>
                      <select id="addHouseType">
                           <option value=1>男生宿舍</option>
                           <option value=2>女生宿舍</option>
                      </select>
                  </td>
               </tr>
               
               
               
               <tr>
                  <td>房租(元/月):</td>
                  <td><input type="text"  id="addHouseRent"></td>
                  <td>支付方式:</td>
                  <td>
                    <select id="addHousePay">
                           <option value=0>月付</option>
                           <option value=1>季付</option>
                           <option value=2>半年付</option>
                           <option value=3>年付</option>
                    </select>
                  </td>
               </tr>
               
               
               <tr>
                  <td>房东:</td>
                  <td>
                     <select id="addHouseLid">
                     </select>
                  </td>
                  <td></td>
                  <td></td>
               </tr>
               
               
               <tr>
                  <td>房间状态:</td>
                  <td>
                      <select id="addHouseStatus">
                           <option value=1>正常</option>
                           <option value=2>设备损坏</option>
                      </select>
                  </td>
                  <td>租房日期:</td>
                  <td><input type="date"  id="addHouseTime"></td>
               </tr>
               
               
               <tr>
                  <td colspan="4" id="addHousetr">
                     <button id="addHouseSubmit">提交</button>
                     <button id="addHouseExit">退出</button>
                  </td>
               </tr>
          </table>
      </div>



















			<%-- 分页查询 --%>
			<div id="pageButton">
				<button id="firstPage">首页</button>
				<button id="prevPage">上一页</button>
				<span id="currentPage">1</span> <span>/</span> <span id="totalPage">1</span>
				<button id="nextPage">下一页</button>
				<button id="lastPage">尾页</button>
			</div>

			<div id="operation">


				<%--班级操作栏 --%>
				<div id="houseOperation">

					<div id="houseOperation-left">
						<div>
							<button id="addhouse">添加房间</button>
							<button id="deletehouse">删除房间</button>
						</div>
						<div>
							<button id="houseInf">查看房间详细</button>
							<button id="houseEqu">查看房间设施</button>
						</div>
					</div>

					<div id="houseOperation-right">
						<div style="text-align: center;">
							<b>查看房间信息</b>
						</div>
						<div>
							&nbsp&nbsp <span>房间地址:<input type="text"
								id="findByAddress"></span> &nbsp&nbsp&nbsp <span>房间状态: <select
								id="findByEq">
									<option value=1>正常</option>
									<option value=2>设备受损</option>
							</select>
							</span>
						</div>
						<div>
							&nbsp&nbsp <span>可住房间: <select id="findByCan">
									<option value=false>不限</option>
									<option value=true>可住</option>
							</select>
							</span> &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp <span>房屋类型: <select
								id="findByType">
									<option value=0>不限</option>
									<option value=1>男生宿舍</option>
									<option value=2>女生宿舍</option>
							</select>
							</span>
						</div>
						<div>
							<button id="findHouse">查找</button>
						</div>
					</div>
				</div>





			</div>



			<!-- <div id="operation">
			    <div id="left">aaa</div>
			    <div id="rght">bbb</div>
			</div> -->
		</div>
	</div>


	<script type="text/javascript">
		$(function() {
			var currentPage = parseInt($("#currentPage").html());

			showHouse(currentPage);
			
			 $("#addHouseExit").click(function(){
				  $("#addHouseDiv").fadeOut("fast");
		  		/* closeblack(); */
			  });
			 
			/*  添加房间; */
			$("#addHouseSubmit").click(function(){
		  var addHouseAddress=$("#addHouseAddress").val();
		  var addHouseSize=parseInt($("#addHouseSize").val());
		  var addHouseSum=parseInt($("#addHouseSum").val());
		  var addHouseType=parseInt($("#addHouseType").val());
		  var addHouseRent=parseInt($("#addHouseRent").val());
		  var addHousePay=parseInt($("#addHousePay").val());
		  var addHouseLid=parseInt($("#addHouseLid").val());
		  var addHouseStatus=parseInt($("#addHouseStatus").val());
		  var addHouseTime=$("#addHouseTime").val();
		  $.ajax({
				url : "house/add",
				type : "post",
				data : {
					"haddress" : addHouseAddress,
					"hsize" : addHouseSize,
					"hsum" : addHouseSum,
					"htype" : addHouseType,
					"hrent" : addHouseRent,
					"hpay" : addHousePay,
					"lid" : addHouseLid,
					"hstatus" : addHouseStatus,
					"htime" : addHouseTime
				},
				dataType : "json",
				success : function(data) {
					if(data>0){
						alert("添加成功");
						$("#addHouseDiv").fadeOut("fast");
			    		/* closeblack(); */
						var currentPage = parseInt($("#currentPage").html());
						showHouse(currentPage);
					}
					else{
						alert("添加失败");
					}
				}
			}); 
	  });
			
			/*条件查询*/
			$("#findHouse").click(function(){
				var address=$("#findByAddress").val();
				var status=parseInt($("#findByEq").val());
				var canlive=$("#findByCan").val();
				if(canlive=="true"){
					canlive=true;
				}else{
					canlive=false;
				}
				var type=parseInt($("#findByType").val());
				showHouseByCon(address,canlive,status,type);
			});
			
			/* 查看房间详细信息 */
			$("#houseInf").click(function(){
				var witchTrInt=parseInt($("#witchTr").val());
				if(witchTrInt>0){
					showOneHouseInf(witchTrInt);
					$("#" + witchTrInt).prop("style","background-color:#ffffff ");
					$("#witchTr").val(0);
				}else{
					alert("未选择目标")
				}
				
			});
			
			/*退出房间详细信息表*/
			$("#showHouseInfExit").click(function(){
				 $("#showHouseInf").fadeOut("fast"); 
		    		/* closeblack();*/
			});
			
			/* 点击添加房间按钮 */
			$("#addhouse").click(function(){
					showAllLandLord();
			});
			

			/* 首页 */
			$("#firstPage").click(function() {
				var current = parseInt($("#currentPage").html());
				if (current > 1) {
					showHouse(1);
				}
			});
			/* 最后一页 */
			$("#lastPage").click(function() {
				var current = parseInt($("#currentPage").html());
				var total = parseInt($("#totalPage").html());
				if (current < total) {
					showHouse(total);
				}
			});

			/* 上一页 */
			$("#prevPage").click(function() {
				var current = parseInt($("#currentPage").html());
				if (current > 1) {
					showHouse(current - 1);
				}
			});

			/* 下一页 */
			$("#nextPage").click(function() {
				var current = parseInt($("#currentPage").html());
				var total = parseInt($("#totalPage").html());
				if (current < total) {
					showHouse(current + 1);
				}
			});
			
			/* 点击查看设备 */
			$("#houseEqu").click(function(){
				$("#houseEquiTable").html("");
				var witchTrInt = parseInt($("#witchTr").val());
				if (witchTrInt > 0) {
					$("#witchOption").val(witchTrInt);
					equipmentMa(witchTrInt);
					var witchTr = $("#witchTr").val();
					$("#" + witchTr).prop("style",
							"background-color:#ffffff ");
					//将哪一行的值为0；
					$("#witchTr").val(0);
				} else {
					alert("未选中目标");
				}
			});
			
			/* equipmentMa(witchTrInt); */
			/* 添加设备损坏记录 */
			$("#addEq").click(function(){
				var witchOption=parseInt($("#witchOption").val());
				var houseEquiE=$("#houseEquiE").val();
				var houseEquiTime=$("#houseEquiTime").val();
				var witchHsta=parseInt($("#witchHsta").val());
			$.ajax({
					url : "equipment/add",
					type : "post",
					data : {
						"einf" : houseEquiE,
						"etime" : houseEquiTime,
						"hid" : witchOption,
						"hstatus" : witchHsta
					},
					dataType : "json",
					success : function(data) {
						if(data>0){
							$("#houseEquiTable").html("");
							equipmentMa(witchOption);
						}
					}
				}); 
			});
				
			
			/*处理设备*/
			$("#deleEq").click(function(){
				var witchTrValue=$("#witchTrValue").val();
				var witchOption=parseInt($("#witchOption").val());
				var witchTrInt=parseInt($("#witchTr").val());
				if( witchTrInt>0){
					if(witchTrValue==0){
						$.ajax({
							url : "equipment/update",
							type : "post",
							data : {
								"eid" : witchTrInt,
								"hid" : witchOption
							},
							dataType : "json",
							success : function(data) {
									$("#houseEquiTable").html("");
									equipmentMa(witchOption);
							}
						}); 
						var witchTr=$("#witchTr").val();
						$("#"+witchTr).prop("style","background-color:#ffffff ");
						$("#witchTr").val(0);
					
					}
					else{
						alert("该设备已经解决了,不能选择");
					}
				}else{
					alert("未选择目标");
				}
				
				
				
			});
			
			
			
			
			
			
			/* 退出设备列表 */
			$("#exitEq").click(function(){
				$("#witchOption").val(0);
				$("#witchOption").val(0);
				$("#witchOption").val(0);
				$("#witchOption").val(0);
				var currentPage = parseInt($("#currentPage").html());
				showHouse(currentPage);
				$("#houseEqui").fadeOut("fast");
	    		/* closeblack(); */
			});
			
			

			/* 删除房间*/
			$("#deletehouse").click(
					function() {
						var witchTrValue = $("#witchTrValue").val();
						var witchTrInt = parseInt($("#witchTr").val());
						if (witchTrInt > 0) {
							if (witchTrValue != 0) {
								alert("该房间含有住户，无法删除!");
							} else {
								$.ajax({
									url : "house/delete",
									type : "post",
									data : {
										hid : witchTrInt
									},
									dataType : "json",
									success : function(data) {
										if (data == "成功") {
											var currentPage = parseInt($(
													"#currentPage").html());
											showHouse(currentPage);
										} else {
											alert(data);
										}
									}
								});
							}
							var witchTr = $("#witchTr").val();
							$("#" + witchTr).prop("style",
									"background-color:#ffffff ");
							//将哪一行的值为0；
							$("#witchTr").val(0);
						} else {
							alert("未选中目标");
						}
					});

		});

		/* 查询操作 */
		function divOnclick1(trId) {
			var witchTr = $("#witchTr").val();
			if (witchTr != "" || witchTr != null) {
				$("#" + witchTr).prop("style", "background-color:#ffffff ");
			}
			$("#" + trId).prop("style", "background-color: #cfcfcf");
			$("#witchTr").val(trId);

		};

		/* 删除操作 */
		/* 点击表格*/
		function divOnclick2(trId, trVal) {
			var witchTr = $("#witchTr").val();
			if (witchTr != "" || witchTr != null) {
				$("#" + witchTr).prop("style", "background-color:#ffffff ");
			}
			$("#" + trId).prop("style", "background-color: #cfcfcf");
			$("#witchTr").val(trId);
			$("#witchTrValue").val(trVal);

		};
		
		/* 删除操作 */
		/* 点击表格*/
		function divOnclick3(trId, trVal,status) {
			var witchTr = $("#witchTr").val();
			if (witchTr != "" || witchTr != null) {
				$("#" + witchTr).prop("style", "background-color:#ffffff ");
			}
			$("#" + trId).prop("style", "background-color: #cfcfcf");
			$("#witchTr").val(trId);
			$("#witchTrValue").val(trVal);
			$("#witchHsta").val(status);
		

		};

		/* 展示房间 					var thead = $("<tbody id=\"tbodyShow\"></tbody>");
					var tbody = $("<tr id=\"theadShow\"></tbody>");*/
		function showHouse(currentPage) {
			$("#tableShow").html("");
			$.ajax({
				url : "house/ShowAllByPage",
				type : "post",
				data : {
					"pageNumber" : currentPage,
					//"count" : 10
				},
				dataType : "json",
				success : function(data) {
					alert(data);
					var table = $("#tableShow");
					var thead = $("<thead id=\"theadShow\"></thead>");
					var tbody = $("<tbody id=\"tbodyShow\"</tbody>");
					var tr = $("<tr></tr>");
					var ta = $("<th></th>").text("房间地址");
					var tn = $("<th></th>").text("容纳人数");
					var tp = $("<th></th>").text("已住人数");
					var tre = $("<th></th>").text("房租");
					var ts = $("<th></th>").text("房间状态");
					var ln = $("<th></th>").text("房东");
					var lp = $("<th></th>").text("房东电话");
					var ht = $("<th></th>").text("房间类型");
					tr.append(ta);
					tr.append(tn);
					tr.append(tp);
					tr.append(tre);
					tr.append(ts);
					tr.append(ln);
					tr.append(lp);
					tr.append(ht);
					thead.append(tr);
					var houses = data.data;
					$("#totalPage").html(data.sumPage);
					$("#currentPage").html(data.currentPage);
					for (var i = 0; i < houses.length; i++) {
						var hlord = houses[i].landlord;
						var btr = $("<tr onclick=\"divOnclick3("
								+ houses[i].hid + "," + houses[i].livingNumber
								+ "," + houses[i].hstatus
								+")\" id=" + houses[i].hid + "></tr>");
						var house = houses[i];
						var haddress = $("<th></th>").text(house.haddress);
						var hsum = $("<th></th>").text(house.hsum);
						var hstude = $("<th></th>").text(house.livingNumber);
						var hrent = $("<th></th>").text(house.hrent + "元/月");
						if (house.hstatus != 2) {
							var hstatus = $("<th></th>").text("正常");
						} else {
							var hstatus = $("<th></th>").text("设备受损");
						}
						var lordname = $("<th></th>").text(hlord.lname);
						var lordPhone = $("<th></th>").text(hlord.lphone);
						if (house.htype != 2) {
							var htype = $("<th></th>").text("男生宿舍");
						} else {
							var htype = $("<th></th>").text("女生宿舍");
						}
						btr.append(haddress);
						btr.append(hsum);
						btr.append(hstude);
						btr.append(hrent);
						btr.append(hstatus);
						btr.append(lordname);
						btr.append(lordPhone);
						btr.append(htype);
						tbody.append(btr);
					}
					table.append(thead);
					table.append(tbody);
				}
			});
			
			
		}
					
	function equipmentMa(witchTrInt) {
		$.ajax({
			url : "house/equipment",
			type : "post",
			data : {
				hid : witchTrInt
			},
			dataType : "json",
			success : function(data) {
				var table = $("#houseEquiTable");
				var thead = $("<thead id=\"houseEquiThead\"></thead>");
				var tbody = $("<tbody id=\"houseEquiTbody\"</tbody>");
				if(data!=""){
					var tr = $("<tr></tr>");
					var ta = $("<th></th>").text("损坏描述");
					var tn = $("<th></th>").text("损坏日期");
					var tp = $("<th></th>").text("是否解决");
					tr.append(ta);
					tr.append(tn);
					tr.append(tp);
					thead.append(tr);
					for (var i = 0; i < data.length; i++){
						var btr = $("<tr onclick=\"divOnclick2("
								+ data[i].eid + "," + data[i].estatus
								+ ")\" id=" + data[i].eid + "></tr>");
						var ta1 = $("<th></th>").text(data[i].einf);
						var tn1 = $("<th></th>").text(data[i].etime);
						if(data[i].estatus!=0){
							var tp1 = $("<th></th>").text("已解决");
						}else{
							var tp1 = $("<th></th>").text("未解决");
						}
						btr.append(ta1);
						btr.append(tn1);
						btr.append(tp1);
						tbody.append(btr);
					}
				}
				table.append(thead);
				table.append(tbody);
				$("#houseEqui").fadeIn("fast");
	 /*    		showblack(); */
			}
		});
	}
	
	
	  function showAllLandLord(){
		  $.ajax({
				url : "landlord/findLandlord",
				type : "post",
				dataType : "json",
				success : function(data) {
					$("#addHouseLid").html("");
					var select=$("#addHouseLid");
					for(var i=0;i<data.length;i++){
						var cname=$("<option value=\""+data[i].lid+"\"></option>").text(data[i].lname);
						select.append(cname);
					}
					$("#addHouseDiv").fadeIn("fast");
					 /*  showblack(); */
				}
	   }); 
	}
	  
	  function showOneHouseInf(hid) {
			$.ajax({
				url : "house/ShowOne",
				type : "post",
				data : {
					"hid" : hid
				},
				dataType : "json",
				success : function(data) {
					var landlord = data.landlord;
					$("#showHouseInfAddress").html(data.haddress);
					switch (data.hsize) {
					case 0:
						$("#showHouseInfSize").html("一室一厅");
						break;
					case 1:
						$("#showHouseInfSize").html("两室一厅");
						break;
					case 2:
						$("#showHouseInfSize").html("三室一厅");
						break;
					case 3:
						$("#showHouseInfSize").html("三室两厅");
						break;
					}
					$("#showHouseInfSum").html(data.hsum);
					$("#showHouseInfNum").html(data.livingNumber);
					$("#showHouseInfRent").html(data.hrent+"元/月");
					
					
					switch (data.hpay) {
					case 0:
						$("#showHouseInfPay").html("月付");
						break;
					case 1:
						$("#showHouseInfPay").html("季付");
						break;
					case 2:
						$("#showHouseInfPay").html("半年付");
						break;
					case 3:
						$("#showHouseInfPay").html("年付");
						break;
					}
					$("#showHouseInfLid").html(landlord.lname);
					$("#showHouseInfLphone").html(landlord.lphone);
					
					
					switch (data.hstatus) {
					case 1:
						$("#showHouseInfStatus").html("正常");
						break;
					case 2:
						$("#showHouseInfStatus").html("设备损坏");
						break;
					}
					switch (data.htype) {
					case 1:
						$("#showHouseInfType").html("男生宿舍");
						break;
					case 2:
						$("#showHouseInfType").html("女生宿舍");
						break;
					}
					$("#showHouseInfTime").html(data.htime);
					var students = data.student;
					var content="";
					for(var i=0;i<students.length;i++){
					content+="<tr>"
						+"<td>"+students[i].sname+"</td>"
						+"<td>"+students[i].cname+"</td>"
						+"<td>"+students[i].sphone+"</td>"
						+"</tr>"
					} 
					$("#showStudentInfTbody").html(content);
					
					$("#showHouseInf").fadeIn("fast");
					 /*  showblack(); */
				}
			});

		}
	  
	  function showHouseByCon(address,canlive,status,type) {
			$("#tableShow").html("");
			$.ajax({
				url : "house/showCondition",
				type : "post",
				data : {
					"currentPage" : 1,
					"count" : 30,
					"haddress":address,
					"canLive":canlive,
					"hstatus":status,
					"htype":type
				},
				dataType : "json",
				success : function(data) {
					var table = $("#tableShow");
					var thead = $("<thead id=\"theadShow\"></thead>");
					var tbody = $("<tbody id=\"tbodyShow\"</tbody>");
					var tr = $("<tr></tr>");
					var ta = $("<th></th>").text("房间地址");
					var tn = $("<th></th>").text("容纳人数");
					var tp = $("<th></th>").text("已住人数");
					var tre = $("<th></th>").text("房租");
					var ts = $("<th></th>").text("房间状态");
					var ln = $("<th></th>").text("房东");
					var lp = $("<th></th>").text("房东电话");
					var ht = $("<th></th>").text("房间类型");
					tr.append(ta);
					tr.append(tn);
					tr.append(tp);
					tr.append(tre);
					tr.append(ts);
					tr.append(ln);
					tr.append(lp);
					tr.append(ht);
					thead.append(tr);
					var houses = data.data;
					$("#totalPage").html(data.sumPage);
					$("#currentPage").html(data.currentPage);
					for (var i = 0; i < houses.length; i++) {
						var hlord = houses[i].landlord;
						var btr = $("<tr onclick=\"divOnclick3("
								+ houses[i].hid + "," + houses[i].livingNumber
								+ "," + houses[i].hstatus
								+")\" id=" + houses[i].hid + "></tr>");
						var house = houses[i];
						var haddress = $("<th></th>").text(house.haddress);
						var hsum = $("<th></th>").text(house.hsum);
						var hstude = $("<th></th>").text(house.livingNumber);
						var hrent = $("<th></th>").text(house.hrent + "元/月");
						if (house.hstatus != 2) {
							var hstatus = $("<th></th>").text("正常");
						} else {
							var hstatus = $("<th></th>").text("设备受损");
						}
						var lordname = $("<th></th>").text(hlord.lname);
						var lordPhone = $("<th></th>").text(hlord.lphone);
						if (house.htype != 2) {
							var htype = $("<th></th>").text("男生宿舍");
						} else {
							var htype = $("<th></th>").text("女生宿舍");
						}
						btr.append(haddress);
						btr.append(hsum);
						btr.append(hstude);
						btr.append(hrent);
						btr.append(hstatus);
						btr.append(lordname);
						btr.append(lordPhone);
						btr.append(htype);
						tbody.append(btr);
					}
					table.append(thead);
					table.append(tbody);
				}
			});
			
			
		}
	</script>

</body>
</html>